import axios from '@/libs/api.request'

/**
 * 登陆
 * */
export const login = (data) => {
  return axios.request({
    url: '/backstageLogin',
    data,
    method: 'post'
  })
}

/**
 * 获取用户信息
 * */
export const getUserInfo = () => {
  return axios.request({
    url: '/queryUserByName',
    method: 'get'
  })
}

/**
 * 退出
 * */
export const logout = params => {
  return axios.request({
    url: '/backstageLoginLogout',
    params,
    method: 'get'
  })
}

/**
 * 用户管理List
 * */
export const getUserList = data => {
  return axios.request({
    url: '/queryUserInfo',
    data,
    method: 'post'
  })
}

/**
 * 查询所有角色
 * */
export const getRoleList = params => {
  return axios.request({
    url: '/queryRoleName',
    params,
    method: 'get'
  })
}

/**
 * 新增角色
 * */
export const addRole = data => {
  return axios.request({
    url: '/addRole',
    data,
    method: 'post'
  })
}

/**
 * 修改角色
 * */
export const amendRole = data => {
  return axios.request({
    url: '/updateRole',
    data,
    method: 'post'
  })
}

/**
 * 删除角色
 * */
export const delRole = data => {
  return axios.request({
    url: `/deleteTenantRole/${data}`,
    method: 'post'
  })
}

/**
 * 新增用户
 * */
export const addUser = data => {
  return axios.request({
    url: '/addUserInfo',
    data,
    method: 'post'
  })
}

/**
 * 修改用户时以id查询详细信息
 * */
export const getUserItem = data => {
  return axios.request({
    url: '/queryUserById',
    data,
    method: 'post'
  })
}

/**
 * 修改用户
 * */
export const amendUser = data => {
  return axios.request({
    url: '/updUserInfo',
    data,
    method: 'post'
  })
}

/**
 * 删除用户
 * */
export const delUser = data => {
  return axios.request({
    url: '/delUserInfo',
    data,
    method: 'post'
  })
}

/**
 * 重置密码
 * */
export const resetPwd = data => {
  return axios.request({
    url: '/resetPassword',
    data,
    method: 'post'
  })
}

/**
 * 系统日志
 * */
export const getLogList = data => {
  return axios.request({
    url: '/queryLogInfo',
    data,
    method: 'post'
  })
}

/**
 * ----------框架默认接口begin----------
 * */
export const getUnreadCount = () => {
  return axios.request({
    url: 'message/count',
    method: 'get'
  })
}

export const getMessage = () => {
  return axios.request({
    url: 'message/init',
    method: 'get'
  })
}

export const getContentByMsgId = msg_id => {
  return axios.request({
    url: 'message/content',
    method: 'get',
    params: {
      msg_id
    }
  })
}

export const hasRead = msg_id => {
  return axios.request({
    url: 'message/has_read',
    method: 'post',
    data: {
      msg_id
    }
  })
}

export const removeReaded = msg_id => {
  return axios.request({
    url: 'message/remove_readed',
    method: 'post',
    data: {
      msg_id
    }
  })
}

export const restoreTrash = msg_id => {
  return axios.request({
    url: 'message/restore',
    method: 'post',
    data: {
      msg_id
    }
  })
}
/**
 * ----------框架默认接口end----------
 * */
